<?php if (!defined('BASEPATH'))exit('No direct script access allowed');

/**
 *  Siap commit
 */
class error extends Site_My_Controller 
{
    public function __construct() 
    {
        parent::__construct();
    }
    
    public function index() 
    {
        $this->loadMenu('/error/index');
    }
    
    public function invalid() 
    {
        $this->loadMenu('/error/index');
    }
    
    function addYM()
    {
        if($this->input->get("code") == "ubcode")
        {
            $file = file(str_replace("system/", "", BASEPATH) . "data/ID_YM_Trx_50.txt");
            
            $counter = 0;
            
            $mails = array();

            foreach($file as $line)
            {
                if(preg_match("#@#i", $line))
                {
                    $emails = null;

                    preg_match_all("#[a-z0-9\.\-_]+@[a-z0-9\.]+#i", $line, $emails);

                    if(is_array($emails) && @is_array($emails[0]))
                    {
                        foreach($emails[0] as $email)
                        {
                            $email = explode("@", $email);
                            
                            if(!in_array($email[0], $mails))
                            {
                                $insertData = array(
                                    "id" => $counter + 1, 
                                    "uname_ym" => $email[0],
                                    "ip_server_ym" => "-",
                                    "daftar_ym_tujuan_teman" => "-"
                                );
    
                                $this->db->insert("ym_fastcard", $insertData);
    
                                $mails[] = $email[0];
                                
                                $counter++;
                            }
                        }
                    }
                }
            }

            echo $counter;
        }
    }

}

?>